package cn.tedu.ivos.application.controller;

import cn.tedu.ivos.application.pojo.dto.ApplicationQuery;
import cn.tedu.ivos.application.pojo.dto.ApplicationSaveDTO;
import cn.tedu.ivos.application.pojo.vo.ApplicationVO;
import cn.tedu.ivos.application.service.ApplicationService;
import cn.tedu.ivos.base.response.JsonResult;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author liyuehui
 * @time 2024/7/15 14:44
 */
@Slf4j
@RestController
@RequestMapping("/v1/application/")
public class AppliactionController {
    @Autowired
    private ApplicationService applicationService;

    /**
     * @param applicationSaveDTO
     * @return JsonResult
     */
    @PostMapping("save")
    @ApiOperation("保存应用信息")
    public JsonResult save(ApplicationSaveDTO applicationSaveDTO) {
        log.debug("保存申请单applicationSaveDTO={}", applicationSaveDTO);
        applicationService.save(applicationSaveDTO);
        return JsonResult.ok();
    }

    /**
     * 查询申请单
     * @param applicationQuery
     * @return JsonResult
     */
    @GetMapping("select")
    @ApiOperation("查询申请单")
    public JsonResult select(ApplicationQuery applicationQuery){
        log.debug("查询申请单:applicationQuery={}",applicationQuery);
        List<ApplicationVO> list = applicationService.selectApplication(applicationQuery);
        return JsonResult.ok(list);
    }
}
